search.parse();

var form = new Form("supplier"), supplier = $("#supplier");

//加载数据
function loadData(entityid) {
	pcGlobal.sendRequest(__ctx + "/supplier/querySupplierDetail.xhtml", {entityid : entityid}, function(data, status) {
		if (data.status) {
			form.setData(data.result);
			
			$("#buslicense").removeClass("table-cell-link-disabled")
							.addClass("table-cell-link")
							.attr("onclick", "showImage('" + data.result.buslicense + "');")
							.attr("title", "点击查看营业执照");
			$("#folicense").removeClass("table-cell-link-disabled")
						   .addClass("table-cell-link")
						   .attr("onclick", "showImage('" + data.result.folicense + "');")
						   .attr("title", "点击查看食品经营许可证");
			if (!data.result.testreport) $("#testreport").attr("title", "未提交此资料");
			else {
				$("#testreport").removeClass("table-cell-link-disabled")
								.addClass("table-cell-link")
								.attr("onclick", "showImage('" + data.result.testreport + "');")
								.attr("title", "点击查看检测报告");
			}
			if (!data.result.qualityreport) $("#qualityreport").attr("title", "未提交此资料");
			else {
				$("#qualityreport").removeClass("table-cell-link-disabled")
								   .addClass("table-cell-link")
								   .attr("onclick", "showImage('" + data.result.qualityreport + "');")
								   .attr("title", "点击查看质量报告");
			}
			
			for (var i = 0; i < data.result.areas.length; i ++) {
				var area = data.result.areas[i];
				var html = "<tr>" + 
							"<td class='lg'><label>" + (i + 1) + "：</label></td>" + 
							"<td class='lg left' colspan='4'>" + 
								"<div id='areaname" + i + "' class='search-label' defaultValue='" + area.areaname + "' width='672' height='26'></div>" + 
							"</td>" + 
						   "</tr>";
				supplier.append($(html));
			}
			search.parse();
		} else search.warn({content : "加载供应商详情失败！"});
	});
}

//显示图片
function showImage(url) {
	var win = $(top.window);
	var data = {
		url : __ctx + "/viewimagedata.xhtml", 
		title : "图片资料", 
		width : win.width(), 
		height : win.height(), 
		onload : function(window) {
			window.loadImage(url);
		}, 
		ondestroy : function(result){
		}
	}
	top.search.popDialog(data);
}
